package com.hup.joystick;

import com.hup.joystick.model.BootOption;
import com.hup.joystick.mvp.MainMvp.MainPresenter;
import com.hup.utils.commons.start.AppInfo;
import com.hup.utils.commons.start.CliHandler;
import com.hup.utils.commons.start.LongBeanNameGenerator;
import com.hup.utils.commons.start.LookThemeUtil;
import com.hup.utils.commons.start.SpringContext;
import com.hup.utils.commons.start.StartUpWindow;
import com.hup.utils.commons.swing.SwingExecutable;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author hugan
 * @date 2020/10/15
 */
@ComponentScan(basePackages = {"com.hup.utils.commons.start", "com.hup.joystick"})
@SpringBootApplication
@AppInfo(chName = "手柄控制器")
public class Joystick {

    public static void main(String[] args) {
        BootOption bootOption = CliHandler.handleArgs(BootOption.class, args);
        //BeanConfig.useJoystickMocker = true;
        LookThemeUtil.initNormal(null);
        StartUpWindow.startUp(() -> init(bootOption, args));
    }

    private static void init(BootOption bootOption, String[] args) throws Exception {
        SpringApplicationBuilder builder = new SpringApplicationBuilder(Joystick.class);
        builder.headless(false).beanNameGenerator(new LongBeanNameGenerator()).run(args);

        SwingExecutable.initSwingExecutor();
        SpringContext.getBean(MainPresenter.class).startUp(bootOption);
    }

}
